﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MotionCS.Helper;
using MotionCS.Controller;
using MotionCS.Config;

namespace MotionCS.Controller
{
    public class MotorStatus
    {
        /// <summary>
        /// 正限位
        /// </summary>
        public bool ElPosLimit { get;set; }
        /// <summary>
        /// 负限位
        /// </summary>
        public bool ElNegLimit { get; set; }
        /// <summary>
        /// 伺服报警
        /// </summary>
        public bool ServoAlarm { get; set; }
        /// <summary>
        /// 伺服使能
        /// </summary>
        public bool ServoOn { get; set; }
        /// <summary>
        /// 急停
        /// </summary>
        public bool EmgStop { get; set; }
    }

    public interface IAxis
    {
        /// <summary>
        /// 轴配置
        /// </summary>
        AxisConfi Config { get; }
        /// <summary>
        /// 设置手动速度
        /// </summary>
        void SetMualSpeed();

        /// <summary>
        /// 设置自动防掉板速度
        /// </summary>
        void SetAutoSpeed2();

        /// <summary>
        /// 设置自动速度
        /// </summary>
        void SetAutoSpeed();
        /// <summary>
        /// 进入回零速度
        /// </summary>
        void SetHomeSpeed();
        /// <summary>
        /// 获取轴运行状态
        /// </summary>
        /// <returns>true-停止 false-运动中</returns>
        bool IsCheckDone();
        /// <summary>
        /// 运动到绝对点
        /// </summary>
        /// <param name="fdis"></param>
        int MoveAbs(double fdis);
        /// <summary>
        /// 运动到相对点
        /// </summary>
        /// <param name="fdis"></param>
        int MoveRel(double fdis);
        /// <summary>
        /// 前向运动
        /// </summary>
        /// <param name="dir"></param>
        int MoveForward();
        /// <summary>
        /// 后向运动
        /// </summary>
        int MoveBackward();
        /// <summary>
        /// 停止运动
        /// </summary>
        int MoveStop();
        /// <summary>
        /// 急停运动
        /// </summary>
        int EmgStop();
        /// <summary>
        /// 回零运动
        /// </summary>
        int MoveHome();
        /// <summary>
        /// 获取状态
        /// </summary>
        /// <returns></returns>
        MotorStatus GetStatus();
        /// <summary>
        /// 是否到位
        /// </summary>
        /// <returns>true 到位 flase 未到位</returns>
        bool IsInp();
        /// <summary>
        /// 是否回零完成
        /// </summary>
        /// <returns>false 回零中 true 回零成功 </returns>
        bool IsHomeFinish();
        /// <summary>
        /// 是否在原点
        /// </summary>
        /// <returns></returns>
        bool IsHomeInOn();
        /// <summary>
        /// 是否触发硬件负限位
        /// </summary>
        /// <returns>false 未触发 true 触发</returns>
        bool IsElRevLimit();
        /// <summary>
        /// 是否触发硬件正限位
        /// </summary>
        /// <returns>false 未触发 true 触发</returns>
        bool IsElFwdLimit();
        /// <summary>
        /// 是否驱动器报警
        /// </summary>
        /// <returns>false 未报警 true 报警</returns>
        bool IsAlarm();
        /// <summary>
        /// 伺服使能
        /// </summary>
        void SevonEnable();
        /// <summary>
        /// 伺服失能
        /// </summary>
        void SevonDisable();
        /// <summary>
        /// 复位使能
        /// </summary>
        void ResetEnable();
        /// <summary>
        /// 复位失能
        /// </summary>
        void ResetDisable();
        /// <summary>
        /// 设置指令位置
        /// </summary>
        /// <param name="dpos"></param>
        int SetPositionUnit(double dpos);
        /// <summary>
        /// 获取指令位置
        /// </summary>
        /// <returns></returns>
        int GetPositionUnit(ref double dpos);
        /// <summary>
        /// 设置编码器反馈位置
        /// </summary>
        /// <param name="mpos"></param>
        int SetEncoderUnit(double dpos);
        /// <summary>
        /// 获取编码器反馈位置
        /// </summary>
        /// <param name="mpos"></param>
        int GetEncoderUnit(ref double mpos);
        /// <summary>
        /// 轴运动速度
        /// </summary>
        /// <param name="speed"></param>
        int GetVpSpeed(ref double speed);
    }
}
